﻿Namespace ControlLibrary

    Public Class dbiWSFStyleControls
        Private XMLToImport As Xml.XmlDocument

#Region "Import Commands"
        ''' <summary>Applies a specified style, based on the chosen options, to a control.  This overload will prompt the user to choose the style file from a file dialog</summary>
        ''' <param name="StyleOptions">The styling options to use</param>
        ''' <param name="myControl">The control to apply the style to</param>
        Public Sub ImportXML(ByVal StyleOptions As Object, ByRef myControl As Object)
            XMLToImport = New Xml.XmlDocument
            Dim OpenFileDialog1 As New Windows.Forms.OpenFileDialog
            OpenFileDialog1.FileName = ""
            OpenFileDialog1.Filter = "XML|*.xml"
            OpenFileDialog1.AddExtension = True

            If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then


                XMLToImport.Load(OpenFileDialog1.FileName)
                TriggerImport(StyleOptions, myControl)

            End If



        End Sub

        ''' <summary>Applies a specified style, based on the chosen options, to a control.  This overload will accept a path to a style file to apply</summary>
        ''' <param name="StyleOptions">The styling options to use</param>
        ''' <param name="myControl">The control to apply the style to</param>
        ''' <param name="FileName">The path and name of the style file to use</param>
        Public Sub ImportXMLFile(ByVal StyleOptions As Object, ByRef myControl As Object, ByVal FileName As String)
            XMLToImport = New Xml.XmlDocument
            XMLToImport.Load(FileName)
            TriggerImport(StyleOptions, myControl)
        End Sub

        ''' <summary>Applies a specified style, based on the chosen options, to a control.  This overload will accept an XMLDocument to use as the styler properties</summary>
        ''' <param name="StyleOptions">The styling options to use</param>
        ''' <param name="myControl">The control to apply the style to</param>
        ''' <param name="StyleFile">The XML.XMLDocument object that contains the XML to apply the style from</param>
        Public Sub ImportXMLDocument(ByVal StyleOptions As Object, ByRef myControl As Object, ByVal StyleFile As Xml.XmlDocument)
            XMLToImport = New Xml.XmlDocument
            XMLToImport = StyleFile
            TriggerImport(StyleOptions, myControl)
        End Sub

        ''' <summary>Applies a specified style, based on the chosen options, to a control.  This overload will accept an XML String to use as the styler properties</summary>
        ''' <param name="StyleOptions">The styling options to use</param>
        ''' <param name="myControl">The control to apply the style to</param>
        ''' <param name="XMLString">The XML string to read the styler values from</param>
        Public Sub ImportXMLWithXMLString(ByVal StyleOptions As Object, ByRef myControl As Object, ByVal XMLString As String)
            XMLToImport = New Xml.XmlDocument
            XMLToImport.LoadXml(XMLString)
            TriggerImport(StyleOptions, myControl)
        End Sub

        ''' <summary>An internal method used to determine which control was passed, and which styling options can be called.</summary>
        ''' <param name="StyleOptions">The styling options to use</param>
        ''' <param name="myControl">The control to apply the style to</param>
        Private Sub TriggerImport(ByVal StyleOptions As Object, ByRef myControl As Object)
            Select Case StyleOptions.Name
                Case "dbiSchedule"
                    If myControl.about.contains("dbiSchedule") Then
                        dbiSchedTimeBarXML(StyleOptions.TimeBars, myControl)
                        dbiSchedListXML(StyleOptions.List, myControl)
                        dbiSchedHeaderXML(StyleOptions.Headers, myControl)
                        dbiSchedTitleXML(StyleOptions.Title, myControl)
                        dbiSchedScheduleControlXML(StyleOptions.ScheduleControl, myControl)
                        dbiSchedPreColumnXML(StyleOptions.PreColumn, myControl)
                        dbiSchedToolTipXML(StyleOptions.ToolTips, myControl)
                        dbiSchedSchedulesXML(StyleOptions.Schedules, myControl)
                    End If
                Case "dbiDayView"
                    If myControl.about.contains("dbiDayView") Then
                        dbiDayViewAppointmentsXML(StyleOptions.Appointments, myControl)
                        dbiDayViewAllDayXML(StyleOptions.AllDay, myControl)
                        dbiDayViewHeaderXML(StyleOptions.Headers, myControl)
                        dbiDayViewTitleXML(StyleOptions.Title, myControl)
                        dbiDayViewDayViewXML(StyleOptions.DayView, myControl)
                        dbiDayViewColumnsXML(StyleOptions.Columns, myControl)
                        dbiDayViewTimeLineXML(StyleOptions.TimeLine, myControl)
                    End If
                Case "dbiList"
                    If myControl.about.contains("dbiList") Then
                        dbiListItemsXML(StyleOptions.Items, myControl)
                        dbiListHeaderXML(StyleOptions.Headers, myControl)
                        dbiListTitleXML(StyleOptions.Title, myControl)
                        dbiListListXML(StyleOptions.List, myControl)
                        dbiListPreColumnXML(StyleOptions.PreColumn, myControl)
                    End If
            End Select
        End Sub

#End Region

#Region "ScheduleXML"
        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiSchedTimeBarXML(ByVal toImport As Boolean, ByRef mySchedule As Dbi.WinControl.Schedule.dbiSchedule)
            If toImport Then
                Try
                    Dim TimeBarsNode As Xml.XmlNode
                    TimeBarsNode = XMLToImport.SelectSingleNode("ScheduleStyles/TimeBars")

                    If Not TimeBarsNode Is Nothing Then
                        mySchedule.TimeBarBackColor = Drawing.Color.FromArgb(CInt(TimeBarsNode.SelectSingleNode("BackColor").InnerText))
                        mySchedule.TimeBarBackColorTo = Drawing.Color.FromArgb(CInt(TimeBarsNode.SelectSingleNode("BackColorTo").InnerText))
                        mySchedule.TimeBarForeColor = Drawing.Color.FromArgb(CInt(TimeBarsNode.SelectSingleNode("ForeColor").InnerText))
                        mySchedule.TimeBarBorderColor = Drawing.Color.FromArgb(CInt(TimeBarsNode.SelectSingleNode("BorderColor").InnerText))
                        mySchedule.LinkLineColor = Drawing.Color.FromArgb(CInt(TimeBarsNode.SelectSingleNode("LinkLineColor").InnerText))
                        mySchedule.TimeBarBorderType = CInt(TimeBarsNode.SelectSingleNode("BorderType").InnerText)
                        mySchedule.TimeBarFillType = CInt(TimeBarsNode.SelectSingleNode("FillType").InnerText)

                        mySchedule.BarSelectBackColor = Drawing.Color.FromArgb(CInt(TimeBarsNode.SelectSingleNode("SelectedBackColor").InnerText))
                        mySchedule.BarSelectBackColorTo = Drawing.Color.FromArgb(CInt(TimeBarsNode.SelectSingleNode("SelectedBackColorTo").InnerText))
                        mySchedule.BarSelectForeColor = Drawing.Color.FromArgb(CInt(TimeBarsNode.SelectSingleNode("SelectedForeColor").InnerText))
                        mySchedule.BarSelectBorderColor = Drawing.Color.FromArgb(CInt(TimeBarsNode.SelectSingleNode("SelectedBorderColor").InnerText))
                        mySchedule.BarSelectFillType = CInt(TimeBarsNode.SelectSingleNode("SelectedFillType").InnerText)
                    End If


                Catch ex As Exception
                    System.Windows.Forms.MessageBox.Show("Please verify that the XML supplied was created in the correct format.", "Invalid XML Format")
                End Try
            End If
        End Sub

        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiSchedListXML(ByVal toImport As Boolean, ByRef mySchedule As Dbi.WinControl.Schedule.dbiSchedule)
            If toImport Then
                Try
                    Dim ListNode As Xml.XmlNode
                    ListNode = XMLToImport.SelectSingleNode("ScheduleStyles/List")

                    If Not ListNode Is Nothing Then
                        mySchedule.ListBackColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("BackColor").InnerText))
                        mySchedule.BodyForeColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("BodyColor").InnerText))
                        mySchedule.ListForeColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("ForeColor").InnerText))
                        mySchedule.ItemHeaderColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("HeaderColor").InnerText))
                        mySchedule.ItemBorder = CInt(ListNode.SelectSingleNode("BorderType").InnerText)

                        mySchedule.SelectedBackColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("SelectedBackColor").InnerText))
                        mySchedule.SelectedBackColorTo = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("SelectedBackColorTo").InnerText))
                        mySchedule.SelectedForeColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("SelectedForeColor").InnerText))
                        mySchedule.SelectedBorderColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("SelectedBorderColor").InnerText))
                        mySchedule.SelectedBorder = CInt(ListNode.SelectSingleNode("SelectedBorderType").InnerText)
                        mySchedule.SelectedFillType = CInt(ListNode.SelectSingleNode("SelectedFillType").InnerText)
                        mySchedule.SelectedStyle = CInt(ListNode.SelectSingleNode("SelectedStyle").InnerText)

                        mySchedule.InactiveBackColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("InactiveBackColor").InnerText))
                        mySchedule.InactiveForeColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("InactiveForeColor").InnerText))
                    End If


                Catch ex As Exception
                    System.Windows.Forms.MessageBox.Show("Please verify that the XML supplied was created in the correct format.", "Invalid XML Format")
                End Try



            End If
        End Sub

        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiSchedToolTipXML(ByVal toImport As Boolean, ByRef mySchedule As Dbi.WinControl.Schedule.dbiSchedule)
            If toImport Then
                Try
                    Dim TipsNode As Xml.XmlNode
                    TipsNode = XMLToImport.SelectSingleNode("ScheduleStyles/ToolTips")

                    If Not TipsNode Is Nothing Then
                        mySchedule.TipsBackColor = Drawing.Color.FromArgb(CInt(TipsNode.SelectSingleNode("BackColor").InnerText))
                        mySchedule.TipsBackColorTo = Drawing.Color.FromArgb(CInt(TipsNode.SelectSingleNode("BackColorTo").InnerText))
                        mySchedule.TipsForeColor = Drawing.Color.FromArgb(CInt(TipsNode.SelectSingleNode("ForeColor").InnerText))
                        mySchedule.TipsBorderColor = Drawing.Color.FromArgb(CInt(TipsNode.SelectSingleNode("BorderColor").InnerText))
                        mySchedule.TipsFillType = CInt(TipsNode.SelectSingleNode("FillType").InnerText)
                    End If


                Catch ex As Exception
                    System.Windows.Forms.MessageBox.Show("Please verify that the XML supplied was created in the correct format.", "Invalid XML Format")
                End Try



            End If
        End Sub

        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiSchedHeaderXML(ByVal toImport As Boolean, ByRef mySchedule As Dbi.WinControl.Schedule.dbiSchedule)
            If toImport Then
                Try

                    Dim HeaderNode As Xml.XmlNode
                    HeaderNode = XMLToImport.SelectSingleNode("ScheduleStyles/Headers")

                    If Not HeaderNode Is Nothing Then
                        mySchedule.HeaderBackColor = Drawing.Color.FromArgb(CInt(HeaderNode.SelectSingleNode("BackColor").InnerText))
                        If HeaderNode.SelectSingleNode("BackColorMiddle").InnerText = "Empty" Then
                            mySchedule.HeaderBackColorMiddle = Drawing.Color.Empty
                        Else
                            mySchedule.HeaderBackColorMiddle = Drawing.Color.FromArgb(CInt(HeaderNode.SelectSingleNode("BackColorMiddle").InnerText))
                        End If

                        mySchedule.HeaderBackColorTo = Drawing.Color.FromArgb(CInt(HeaderNode.SelectSingleNode("BackColorTo").InnerText))
                        mySchedule.HeaderForeColor = Drawing.Color.FromArgb(CInt(HeaderNode.SelectSingleNode("ForeColor").InnerText))
                        mySchedule.HeaderOverColor = Drawing.Color.FromArgb(CInt(HeaderNode.SelectSingleNode("OverColor").InnerText))
                        mySchedule.HeaderDownColor = Drawing.Color.FromArgb(CInt(HeaderNode.SelectSingleNode("DownColor").InnerText))

                        mySchedule.HeaderFillType = CInt(HeaderNode.SelectSingleNode("FillType").InnerText)
                        mySchedule.HeaderBorder = CInt(HeaderNode.SelectSingleNode("BorderType").InnerText)
                        mySchedule.HeaderStyle = CInt(HeaderNode.SelectSingleNode("Style").InnerText)
                    End If

                Catch ex As Exception
                    System.Windows.Forms.MessageBox.Show("Please verify that the XML supplied was created in the correct format.", "Invalid XML Format")
                End Try

            End If
        End Sub

        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiSchedTitleXML(ByVal toImport As Boolean, ByRef mySchedule As Dbi.WinControl.Schedule.dbiSchedule)
            If toImport Then
                Try
                    Dim TitleNode As Xml.XmlNode
                    TitleNode = XMLToImport.SelectSingleNode("ScheduleStyles/Title")

                    If Not TitleNode Is Nothing Then
                        mySchedule.TitleBackColor = Drawing.Color.FromArgb(CInt(TitleNode.SelectSingleNode("BackColor").InnerText))
                        If TitleNode.SelectSingleNode("BackColorMiddle").InnerText = "Empty" Then
                            mySchedule.TitleBackColorMiddle = Drawing.Color.Empty
                        Else
                            mySchedule.TitleBackColorMiddle = Drawing.Color.FromArgb(CInt(TitleNode.SelectSingleNode("BackColorMiddle").InnerText))
                        End If
                        mySchedule.TitleBackColorTo = Drawing.Color.FromArgb(CInt(TitleNode.SelectSingleNode("BackColorTo").InnerText))
                        mySchedule.TitleForeColor = Drawing.Color.FromArgb(CInt(TitleNode.SelectSingleNode("ForeColor").InnerText))

                        mySchedule.TitleFillType = CInt(TitleNode.SelectSingleNode("FillType").InnerText)
                        mySchedule.TitleBorder = CInt(TitleNode.SelectSingleNode("BorderType").InnerText)
                    End If

                Catch ex As Exception
                    System.Windows.Forms.MessageBox.Show("Please verify that the XML supplied was created in the correct format.", "Invalid XML Format")
                End Try

            End If
        End Sub

        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiSchedScheduleControlXML(ByVal toImport As Boolean, ByRef mySchedule As Dbi.WinControl.Schedule.dbiSchedule)
            If toImport Then
                Try
                    Dim ScheduleNode As Xml.XmlNode
                    ScheduleNode = XMLToImport.SelectSingleNode("ScheduleStyles/Schedule")

                    If Not ScheduleNode Is Nothing Then
                        mySchedule.AltColorEven = Drawing.Color.FromArgb(CInt(ScheduleNode.SelectSingleNode("AlternateEvenColor").InnerText))
                        mySchedule.AltColorOdd = Drawing.Color.FromArgb(CInt(ScheduleNode.SelectSingleNode("AlternateOddColor").InnerText))

                        mySchedule.BorderColor = Drawing.Color.FromArgb(CInt(ScheduleNode.SelectSingleNode("BorderColor").InnerText))
                        mySchedule.BorderType = CInt(ScheduleNode.SelectSingleNode("BorderType").InnerText)

                        mySchedule.CurrentTimeColor = Drawing.Color.FromArgb(CInt(ScheduleNode.SelectSingleNode("CurrentTimeColor").InnerText))
                        mySchedule.CurrentTimeColorTo = Drawing.Color.FromArgb(CInt(ScheduleNode.SelectSingleNode("CurrentTimeColorTo").InnerText))

                        mySchedule.GuideLineColor = Drawing.Color.FromArgb(CInt(ScheduleNode.SelectSingleNode("GuideLineBackColor").InnerText))
                        mySchedule.GuideSelectColor = Drawing.Color.FromArgb(CInt(ScheduleNode.SelectSingleNode("GuideLineSelectedBackColor").InnerText))

                        mySchedule.SplitterBarColor = Drawing.Color.FromArgb(CInt(ScheduleNode.SelectSingleNode("SplitterBackColor").InnerText))
                    End If

                Catch ex As Exception
                    System.Windows.Forms.MessageBox.Show("Please verify that the XML supplied was created in the correct format.", "Invalid XML Format")
                End Try

            End If
        End Sub

        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiSchedPreColumnXML(ByVal toImport As Boolean, ByRef mySchedule As Dbi.WinControl.Schedule.dbiSchedule)
            If toImport Then
                Try
                    Dim PreColumnNode As Xml.XmlNode
                    PreColumnNode = XMLToImport.SelectSingleNode("ScheduleStyles/PreColumn")

                    If Not PreColumnNode Is Nothing Then
                        mySchedule.PreColumnBackColor = Drawing.Color.FromArgb(CInt(PreColumnNode.SelectSingleNode("BackColor").InnerText))
                        mySchedule.PreColumnBackColorTo = Drawing.Color.FromArgb(CInt(PreColumnNode.SelectSingleNode("BackColorTo").InnerText))
                        mySchedule.PreColumnForeColor = Drawing.Color.FromArgb(CInt(PreColumnNode.SelectSingleNode("ForeColor").InnerText))
                        mySchedule.PreColumnFillType = CInt(PreColumnNode.SelectSingleNode("FillType").InnerText)
                        mySchedule.PreColumnBorder = CInt(PreColumnNode.SelectSingleNode("BorderType").InnerText)

                        mySchedule.PreSelectBackColor = Drawing.Color.FromArgb(CInt(PreColumnNode.SelectSingleNode("SelectedBackColor").InnerText))
                        mySchedule.PreSelectForeColor = Drawing.Color.FromArgb(CInt(PreColumnNode.SelectSingleNode("SelectedForeColor").InnerText))
                        mySchedule.PreSelectBorder = CInt(PreColumnNode.SelectSingleNode("SelectedBorderType").InnerText)
                    End If

                Catch ex As Exception
                    System.Windows.Forms.MessageBox.Show("Please verify that the XML supplied was created in the correct format.", "Invalid XML Format")
                End Try



            End If
        End Sub

        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiSchedSchedulesXML(ByVal toImport As Boolean, ByRef mySchedule As Dbi.WinControl.Schedule.dbiSchedule)
            If toImport Then
                Try
                    Dim SchedulesNode As Xml.XmlNode
                    SchedulesNode = XMLToImport.SelectSingleNode("ScheduleStyles/Schedules")

                    mySchedule.RulerBackColor = Drawing.Color.FromArgb(CInt(SchedulesNode.SelectSingleNode("RulerBackColor").InnerText))
                    mySchedule.RulerBackColorTo = Drawing.Color.FromArgb(CInt(SchedulesNode.SelectSingleNode("RulerBackColorTo").InnerText))
                    mySchedule.RulerForeColor = Drawing.Color.FromArgb(CInt(SchedulesNode.SelectSingleNode("RulerForeColor").InnerText))
                    mySchedule.RulerLineColor = Drawing.Color.FromArgb(CInt(SchedulesNode.SelectSingleNode("RulerLineColor").InnerText))
                    mySchedule.RulerFillType = CInt(SchedulesNode.SelectSingleNode("RulerFillType").InnerText)
                    mySchedule.RulerBorder = CInt(SchedulesNode.SelectSingleNode("RulerBorderType").InnerText)

                    mySchedule.SchedAltColorEven = Drawing.Color.FromArgb(CInt(SchedulesNode.SelectSingleNode("AlternateEvenColor").InnerText))
                    mySchedule.SchedAltColorOdd = Drawing.Color.FromArgb(CInt(SchedulesNode.SelectSingleNode("AlternateOddColor").InnerText))
                    mySchedule.ScheduleBackColor = Drawing.Color.FromArgb(CInt(SchedulesNode.SelectSingleNode("BackColor").InnerText))
                    mySchedule.ScheduleLineColor = Drawing.Color.FromArgb(CInt(SchedulesNode.SelectSingleNode("LineColor").InnerText))




                Catch ex As Exception
                    System.Windows.Forms.MessageBox.Show("Please verify that the XML supplied was created in the correct format.", "Invalid XML Format")
                End Try



            End If
        End Sub
#End Region

#Region "DayViewXML"
        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiDayViewAllDayXML(ByVal toImport As Boolean, ByRef MyDayView As Dbi.WinControl.DayView.dbiDayView)
            If toImport Then
                Try
                    Dim AllDayNode As Xml.XmlNode
                    AllDayNode = XMLToImport.SelectSingleNode("DayViewStyles/AllDay")

                    MyDayView.AllDayBackColor = Drawing.Color.FromArgb(CInt(AllDayNode.SelectSingleNode("BackColor").InnerText))
                    MyDayView.AllDayBackColorTo = Drawing.Color.FromArgb(CInt(AllDayNode.SelectSingleNode("BackColorTo").InnerText))
                    MyDayView.AllDayFillType = CInt(AllDayNode.SelectSingleNode("FillType").InnerText)

                    MyDayView.ArrowBackColor = Drawing.Color.FromArgb(CInt(AllDayNode.SelectSingleNode("ArrowBackColor").InnerText))
                    MyDayView.ArrowForeColor = Drawing.Color.FromArgb(CInt(AllDayNode.SelectSingleNode("ArrowForeColor").InnerText))



                Catch ex As Exception
                    System.Windows.Forms.MessageBox.Show("AllDay XML Error")
                End Try



            End If
        End Sub

        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiDayViewTimeLineXML(ByVal toImport As Boolean, ByRef MyDayView As Dbi.WinControl.DayView.dbiDayView)
            If toImport Then
                Try
                    Dim TimeLineNode As Xml.XmlNode
                    TimeLineNode = XMLToImport.SelectSingleNode("DayViewStyles/TimeLine")

                    MyDayView.TimeBackColor = Drawing.Color.FromArgb(CInt(TimeLineNode.SelectSingleNode("BackColor").InnerText))
                    MyDayView.TimeBackColorTo = Drawing.Color.FromArgb(CInt(TimeLineNode.SelectSingleNode("BackColorTo").InnerText))
                    MyDayView.TimeForeColor = Drawing.Color.FromArgb(CInt(TimeLineNode.SelectSingleNode("ForeColor").InnerText))
                    MyDayView.TimeFillType = CInt(TimeLineNode.SelectSingleNode("FillType").InnerText)
                    MyDayView.TimeBorder = CInt(TimeLineNode.SelectSingleNode("BorderType").InnerText)
                    MyDayView.TimeBorderStyle = CInt(TimeLineNode.SelectSingleNode("BorderStyle").InnerText)

                    MyDayView.CurrentTimeColor = Drawing.Color.FromArgb(CInt(TimeLineNode.SelectSingleNode("CurrentTimeBackColor").InnerText))
                    MyDayView.CurrentShadowColor = Drawing.Color.FromArgb(CInt(TimeLineNode.SelectSingleNode("CurrentTimeShadowColor").InnerText))



                Catch ex As Exception
                    System.Windows.Forms.MessageBox.Show("TimeLineXML Error")
                End Try



            End If
        End Sub

        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiDayViewAppointmentsXML(ByVal toImport As Boolean, ByRef MyDayView As Dbi.WinControl.DayView.dbiDayView)
            If toImport Then
                Try
                    Dim AppointmentsNode As Xml.XmlNode
                    AppointmentsNode = XMLToImport.SelectSingleNode("DayViewStyles/Appointments")

                    MyDayView.AppointmentBackColor = Drawing.Color.FromArgb(CInt(AppointmentsNode.SelectSingleNode("BackColor").InnerText))
                    MyDayView.AppointmentBackColorTo = Drawing.Color.FromArgb(CInt(AppointmentsNode.SelectSingleNode("BackColorTo").InnerText))
                    MyDayView.AppointmentBorderColor = Drawing.Color.FromArgb(CInt(AppointmentsNode.SelectSingleNode("BorderColor").InnerText))
                    MyDayView.AppointmentForeColor = Drawing.Color.FromArgb(CInt(AppointmentsNode.SelectSingleNode("ForeColor").InnerText))
                    MyDayView.AppointmentFillType = CInt(AppointmentsNode.SelectSingleNode("FillType").InnerText)

                    If AppointmentsNode.SelectSingleNode("TaskBarColor").InnerText = "Empty" Then
                        MyDayView.TaskBarColor = Drawing.Color.Empty
                    Else
                        MyDayView.TaskBarColor = Drawing.Color.FromArgb(CInt(AppointmentsNode.SelectSingleNode("TaskBarColor").InnerText))
                    End If
                    MyDayView.BarBottomColor = Drawing.Color.FromArgb(CInt(AppointmentsNode.SelectSingleNode("BarBottomColor").InnerText))
                    MyDayView.BarTopColor = Drawing.Color.FromArgb(CInt(AppointmentsNode.SelectSingleNode("BarTopColor").InnerText))




                Catch ex As Exception
                    System.Windows.Forms.MessageBox.Show("AppointmentsXML Error")
                End Try
            End If
        End Sub

        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiDayViewHeaderXML(ByVal toImport As Boolean, ByRef MyDayView As Dbi.WinControl.DayView.dbiDayView)
            If toImport Then
                Try

                    Dim HeaderNode As Xml.XmlNode
                    HeaderNode = XMLToImport.SelectSingleNode("DayViewStyles/Headers")

                    MyDayView.HeaderBackColor = Drawing.Color.FromArgb(CInt(HeaderNode.SelectSingleNode("BackColor").InnerText))
                    MyDayView.HeaderBackColorTo = Drawing.Color.FromArgb(CInt(HeaderNode.SelectSingleNode("BackColorTo").InnerText))
                    MyDayView.HeaderForeColor = Drawing.Color.FromArgb(CInt(HeaderNode.SelectSingleNode("ForeColor").InnerText))
                    MyDayView.HeaderBorderColor = Drawing.Color.FromArgb(CInt(HeaderNode.SelectSingleNode("BorderColor").InnerText))
                    MyDayView.HeaderFillType = CInt(HeaderNode.SelectSingleNode("FillType").InnerText)
                    MyDayView.HeaderBorderType = CInt(HeaderNode.SelectSingleNode("BorderType").InnerText)

                Catch ex As Exception
                    System.Windows.Forms.MessageBox.Show("HeaderXML Error")
                End Try

            End If
        End Sub

        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiDayViewTitleXML(ByVal toImport As Boolean, ByRef MyDayView As Dbi.WinControl.DayView.dbiDayView)
            If toImport Then
                Try
                    Dim TitleNode As Xml.XmlNode
                    TitleNode = XMLToImport.SelectSingleNode("DayViewStyles/Title")

                    MyDayView.TitleBackColor = Drawing.Color.FromArgb(CInt(TitleNode.SelectSingleNode("BackColor").InnerText))
                    MyDayView.TitleBackColorTo = Drawing.Color.FromArgb(CInt(TitleNode.SelectSingleNode("BackColorTo").InnerText))
                    MyDayView.TitleForeColor = Drawing.Color.FromArgb(CInt(TitleNode.SelectSingleNode("ForeColor").InnerText))
                    MyDayView.TitleFillType = CInt(TitleNode.SelectSingleNode("FillType").InnerText)
                    MyDayView.TitleBorder = CInt(TitleNode.SelectSingleNode("BorderType").InnerText)



                Catch ex As Exception
                    System.Windows.Forms.MessageBox.Show("TitleXML Error")
                End Try

            End If
        End Sub

        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiDayViewDayViewXML(ByVal toImport As Boolean, ByRef MyDayView As Dbi.WinControl.DayView.dbiDayView)
            If toImport Then
                Try
                    Dim DayViewNode As Xml.XmlNode
                    DayViewNode = XMLToImport.SelectSingleNode("DayViewStyles/DayView")

                    MyDayView.BackColor = Drawing.Color.FromArgb(CInt(DayViewNode.SelectSingleNode("BackColor").InnerText))
                    MyDayView.BorderColor = Drawing.Color.FromArgb(CInt(DayViewNode.SelectSingleNode("BorderColor").InnerText))

                    MyDayView.HourLineColor = Drawing.Color.FromArgb(CInt(DayViewNode.SelectSingleNode("HourLine").InnerText))
                    MyDayView.MinuteLineColor = Drawing.Color.FromArgb(CInt(DayViewNode.SelectSingleNode("MinuteLineColor").InnerText))

                    MyDayView.PrimeTimeColor = Drawing.Color.FromArgb(CInt(DayViewNode.SelectSingleNode("PrimeTime").InnerText))
                    MyDayView.NonPrimeColor = Drawing.Color.FromArgb(CInt(DayViewNode.SelectSingleNode("NonPrimeTime").InnerText))

                    MyDayView.SelectedBackColor = Drawing.Color.FromArgb(CInt(DayViewNode.SelectSingleNode("SelectedBackColor").InnerText))
                    MyDayView.SelectedForeColor = Drawing.Color.FromArgb(CInt(DayViewNode.SelectSingleNode("SelectedForeColor").InnerText))

                    MyDayView.TodayBackColor = Drawing.Color.FromArgb(CInt(DayViewNode.SelectSingleNode("TodayBackColor").InnerText))
                    MyDayView.TodayBackColorTo = Drawing.Color.FromArgb(CInt(DayViewNode.SelectSingleNode("TodayBackColorTo").InnerText))
                    MyDayView.TodayFillType = CInt(DayViewNode.SelectSingleNode("TodayBackFill").InnerText)
                    MyDayView.TodayDisplayStyle = CInt(DayViewNode.SelectSingleNode("TodayDisplayStyle").InnerText)

                Catch ex As Exception
                    System.Windows.Forms.MessageBox.Show("DayViewXML Error")
                End Try

            End If
        End Sub

        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiDayViewColumnsXML(ByVal toImport As Boolean, ByRef MyDayView As Dbi.WinControl.DayView.dbiDayView)
            If toImport Then
                Try
                    Dim ColumnsNode As Xml.XmlNode
                    ColumnsNode = XMLToImport.SelectSingleNode("DayViewStyles/Columns")

                    MyDayView.ColumnSepColor = Drawing.Color.FromArgb(CInt(ColumnsNode.SelectSingleNode("BackColor").InnerText))
                    MyDayView.ColumnSepColorTo = Drawing.Color.FromArgb(CInt(ColumnsNode.SelectSingleNode("BackColorTo").InnerText))
                    MyDayView.ColumnSepFillType = CInt(ColumnsNode.SelectSingleNode("FillType").InnerText)

                Catch ex As Exception
                    System.Windows.Forms.MessageBox.Show("ColumnsXML Error")
                End Try



            End If
        End Sub
#End Region

#Region "List"
        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiListItemsXML(ByVal toImport As Boolean, ByRef MyList As Dbi.WinControl.List.dbiList)
            If toImport Then
                Try
                    Dim ListNode As Xml.XmlNode
                    ListNode = XMLToImport.SelectSingleNode("ListStyles/List")

                    MyList.BodyForeColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("BodyColor").InnerText))
                    MyList.ForeColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("ForeColor").InnerText))
                    MyList.ItemHeaderColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("HeaderColor").InnerText))
                    MyList.ItemBorder = CInt(ListNode.SelectSingleNode("BorderType").InnerText)
                    MyList.FocusColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("FocusLineColor").InnerText))

                    MyList.SelectedBackColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("SelectedBackColor").InnerText))
                    MyList.SelectedBackColorTo = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("SelectedBackColorTo").InnerText))
                    MyList.SelectedForeColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("SelectedForeColor").InnerText))
                    MyList.SelectedBorderColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("SelectedBorderColor").InnerText))
                    MyList.SelectedBorder = CInt(ListNode.SelectSingleNode("SelectedBorderType").InnerText)
                    MyList.SelectedFillType = CInt(ListNode.SelectSingleNode("SelectedFillType").InnerText)
                    MyList.SelectedStyle = CInt(ListNode.SelectSingleNode("SelectedStyle").InnerText)

                    MyList.InactiveBackColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("InactiveBackColor").InnerText))
                    MyList.InactiveForeColor = Drawing.Color.FromArgb(CInt(ListNode.SelectSingleNode("InactiveForeColor").InnerText))



                Catch ex As Exception

                End Try



            End If
        End Sub

        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiListHeaderXML(ByVal toImport As Boolean, ByRef MyList As Dbi.WinControl.List.dbiList)
            If toImport Then
                Try

                    Dim HeaderNode As Xml.XmlNode
                    HeaderNode = XMLToImport.SelectSingleNode("ListStyles/Headers")

                    MyList.HeaderBackColor = Drawing.Color.FromArgb(CInt(HeaderNode.SelectSingleNode("BackColor").InnerText))
                    If HeaderNode.SelectSingleNode("BackColorMiddle").InnerText = "Empty" Then
                        MyList.HeaderBackColorMiddle = Drawing.Color.Empty
                    Else
                        MyList.HeaderBackColorMiddle = Drawing.Color.FromArgb(CInt(HeaderNode.SelectSingleNode("BackColorMiddle").InnerText))
                    End If

                    MyList.HeaderBackColorTo = Drawing.Color.FromArgb(CInt(HeaderNode.SelectSingleNode("BackColorTo").InnerText))
                    MyList.HeaderForeColor = Drawing.Color.FromArgb(CInt(HeaderNode.SelectSingleNode("ForeColor").InnerText))
                    MyList.HeaderOverColor = Drawing.Color.FromArgb(CInt(HeaderNode.SelectSingleNode("OverColor").InnerText))
                    MyList.HeaderDownColor = Drawing.Color.FromArgb(CInt(HeaderNode.SelectSingleNode("DownColor").InnerText))

                    MyList.HeaderFillType = CInt(HeaderNode.SelectSingleNode("FillType").InnerText)
                    MyList.HeaderBorder = CInt(HeaderNode.SelectSingleNode("BorderType").InnerText)
                    MyList.HeaderStyle = CInt(HeaderNode.SelectSingleNode("Style").InnerText)

                Catch ex As Exception

                End Try

            End If
        End Sub

        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiListTitleXML(ByVal toImport As Boolean, ByRef MyList As Dbi.WinControl.List.dbiList)
            If toImport Then
                Try
                    Dim TitleNode As Xml.XmlNode
                    TitleNode = XMLToImport.SelectSingleNode("ListStyles/Title")

                    MyList.TitleBackColor = Drawing.Color.FromArgb(CInt(TitleNode.SelectSingleNode("BackColor").InnerText))
                    If TitleNode.SelectSingleNode("BackColorMiddle").InnerText = "Empty" Then
                        MyList.TitleBackColorMiddle = Drawing.Color.Empty
                    Else
                        MyList.TitleBackColorMiddle = Drawing.Color.FromArgb(CInt(TitleNode.SelectSingleNode("BackColorMiddle").InnerText))
                    End If

                    MyList.TitleBackColorTo = Drawing.Color.FromArgb(CInt(TitleNode.SelectSingleNode("BackColorTo").InnerText))
                    MyList.TitleForeColor = Drawing.Color.FromArgb(CInt(TitleNode.SelectSingleNode("ForeColor").InnerText))

                    MyList.TitleFillType = CInt(TitleNode.SelectSingleNode("FillType").InnerText)
                    MyList.TitleBorder = CInt(TitleNode.SelectSingleNode("BorderType").InnerText)


                Catch ex As Exception

                End Try

            End If
        End Sub

        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiListListXML(ByVal toImport As Boolean, ByRef MyList As Dbi.WinControl.List.dbiList)
            If toImport Then
                Try
                    Dim ScheduleNode As Xml.XmlNode
                    ScheduleNode = XMLToImport.SelectSingleNode("ListStyles/Schedule")

                    MyList.AltColorEven = Drawing.Color.FromArgb(CInt(ScheduleNode.SelectSingleNode("AlternateEvenColor").InnerText))
                    MyList.AltColorOdd = Drawing.Color.FromArgb(CInt(ScheduleNode.SelectSingleNode("AlternateOddColor").InnerText))

                    MyList.BorderColor = Drawing.Color.FromArgb(CInt(ScheduleNode.SelectSingleNode("BorderColor").InnerText))
                    MyList.BorderType = CInt(ScheduleNode.SelectSingleNode("BorderType").InnerText)

                    MyList.BackColor = Drawing.Color.FromArgb(CInt(ScheduleNode.SelectSingleNode("BackColor").InnerText))
                    MyList.BackColorTo = Drawing.Color.FromArgb(CInt(ScheduleNode.SelectSingleNode("BackColorTo").InnerText))
                    MyList.BackFillType = CInt(ScheduleNode.SelectSingleNode("BackFillType").InnerText)

                    MyList.LineColor = Drawing.Color.FromArgb(CInt(ScheduleNode.SelectSingleNode("LineColor").InnerText))
                    MyList.LineType = CInt(ScheduleNode.SelectSingleNode("LineType").InnerText)

                    MyList.HorzGridColor = Drawing.Color.FromArgb(CInt(ScheduleNode.SelectSingleNode("HorzLineColor").InnerText))
                    MyList.VertGridColor = Drawing.Color.FromArgb(CInt(ScheduleNode.SelectSingleNode("VertLineColor").InnerText))

                Catch ex As Exception

                End Try

            End If
        End Sub

        ''' <summary>Internal subs to parse the XML and set properties on the controls.</summary>
        Private Sub dbiListPreColumnXML(ByVal toImport As Boolean, ByRef MyList As Dbi.WinControl.List.dbiList)
            If toImport Then
                Try
                    Dim PreColumnNode As Xml.XmlNode
                    PreColumnNode = XMLToImport.SelectSingleNode("ListStyles/PreColumn")

                    MyList.PreColumnBackColor = Drawing.Color.FromArgb(CInt(PreColumnNode.SelectSingleNode("BackColor").InnerText))
                    MyList.PreColumnBackColorTo = Drawing.Color.FromArgb(CInt(PreColumnNode.SelectSingleNode("BackColorTo").InnerText))
                    MyList.PreColumnForeColor = Drawing.Color.FromArgb(CInt(PreColumnNode.SelectSingleNode("ForeColor").InnerText))
                    MyList.PreColumnFillType = CInt(PreColumnNode.SelectSingleNode("FillType").InnerText)
                    MyList.PreColumnBorder = CInt(PreColumnNode.SelectSingleNode("BorderType").InnerText)

                    MyList.PreSelectBackColor = Drawing.Color.FromArgb(CInt(PreColumnNode.SelectSingleNode("SelectedBackColor").InnerText))
                    MyList.PreSelectForeColor = Drawing.Color.FromArgb(CInt(PreColumnNode.SelectSingleNode("SelectedForeColor").InnerText))
                    MyList.PreSelectBorder = CInt(PreColumnNode.SelectSingleNode("SelectedBorderType").InnerText)

                Catch ex As Exception

                End Try



            End If
        End Sub
#End Region
    End Class
End Namespace
